/********************************************************************************
 *      Copyright:  (C) 2022 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  socket.h
 *    Description:  This head file is for socket API functions
 *
 *        Version:  1.0.0(18/04/22)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "18/04/22 17:09:59"
 *
 ********************************************************************************/

#ifndef  _SOCKET_H_
#define  _SOCKET_H_

#define HOST_LEN          64

typedef struct socket_s
{
    char        host[HOST_LEN]; /* CLIENT: Connect server hostname; SERVER: Unused */
    int         port;               /* CLIENT: Connect server port;     SERVER: listen port */
    int         fd;                 /* socket descriptor  */
} socket_t;

extern int socket_init(socket_t *sock, char *host, int port);

extern int socket_close(socket_t *sock);

extern int socket_connect(socket_t *sock);

extern int socket_senddata(socket_t *sock, char *data, int bytes);

extern int socket_alive(int fd);
#endif
